package cn.itcast.rnk.collection;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Collection;

public class TutQueue {

	public static void main(String[] args) throws InterruptedException {

		// testCoundTown();

		ArrayList<String> list = new ArrayList<String>();
		list.add(0, "a");
		list.add(1, "b");
		list.add(2, "c");
		list.add(3, "d");
		list.add(4, "d");
		list.add(5, "d");
		List<String> sort = heapSort(list);
		System.out.println(sort);

	}

	static <E> List<String> heapSort(Collection<String> c) {
		Queue<String> queue = new PriorityQueue<String>(c);
		List<String> result = new ArrayList<String>();

		while (!queue.isEmpty())
			result.add(queue.remove());

		return result;
	}

	private static void testHeapSort() {

	}

	private static void testCoundTown() throws InterruptedException {
		int time = Integer.parseInt("10");
		Queue<Integer> queue = new LinkedList<Integer>();

		for (int i = time; i >= 0; i--)
			queue.add(i);

		while (!queue.isEmpty()) {
			System.out.println(queue.remove());
			Thread.sleep(1000);
		}
	}
}
